﻿<navigation:Page x:Class="LEEAAttendanceControl.Views.WorkDays" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
           xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
           xmlns:my="clr-namespace:LEEAAttendanceControl.Web.Services"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Work Days">
    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <Style x:Key="DataGridHeaderStyle" TargetType="sdk:DataGridColumnHeader">
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>

                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Grid x:Name="RootGrid">
                                <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                <Rectangle Stretch="Fill">
                                    <Rectangle.Fill>
                                        <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                            <GradientStop Color="#FCFFFFFF" Offset="0.015"/>
                                            <GradientStop Color="#F7FFFFFF" Offset="0.375"/>
                                            <GradientStop Color="#E5FFFFFF" Offset="0.6"/>
                                            <GradientStop Color="#D1FFFFFF" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Rectangle.Fill>
                                </Rectangle>

                                <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch" Width="1" HorizontalAlignment="Right"/>

                                <CheckBox x:Name="SelectAllCheckBox" Click="SelectAllCheckBox_Click"  Margin="2,0,0,0"
                                          VerticalAlignment="Center" HorizontalAlignment="Center"/>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
        
        <ScrollViewer VerticalScrollBarVisibility="Auto">
            <StackPanel>
                <Grid Background="#404041">
                    <TextBlock Text="Work Days" Foreground="White" FontSize="14" FontWeight="Bold" Margin="5,3,2,2"
                               HorizontalAlignment="Left"/>
                </Grid>
                
                <riaControls:DomainDataSource x:Name="DaysDataSource" QueryName="GetWeekDays" AutoLoad="True">
                    <riaControls:DomainDataSource.DomainContext>
                        <my:LEEAContext />
                    </riaControls:DomainDataSource.DomainContext>
                </riaControls:DomainDataSource>

                <Grid HorizontalAlignment="Center" Margin="0,25,0,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    
                    <sdk:DataGrid x:Name="DaysGrid" AutoGenerateColumns="False" Width="202" Grid.Row="0"
                              ItemsSource="{Binding Data, ElementName=DaysDataSource}">
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTemplateColumn Header="Day" CanUserReorder="False" CanUserResize="False" Width="130"
                                                    IsReadOnly="True">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <sdk:Label Content="{Binding DayName}" Height="25" Margin="5,0,0,0"
                                               HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn CanUserReorder="False" CanUserResize="False" Width="70"
                                                    HeaderStyle="{StaticResource DataGridHeaderStyle}">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox x:Name="DaySelector" HorizontalAlignment="Center" VerticalAlignment="Center"
                                              Click="DaySelector_Click"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>

                    <Button x:Name="ApplyButton" Content="Apply" Height="25" Width="70" HorizontalAlignment="Right"
                            Grid.Row="1" Margin="0,25,0,0" Click="ApplyButton_Click"/>
                </Grid>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</navigation:Page>
